import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Ad } from "../../entities/ad.entities";
import { TypeOrmCrudService } from '@nestjsx/crud-typeorm';
import { AdPosition } from '../../entities/ad_position.entities';

@Injectable()
export class AdService extends TypeOrmCrudService<Ad>{
  constructor(
    @InjectRepository(Ad)
    private readonly adRepository: Repository<Ad>
  ){
    super(adRepository);
  }

  async save(){
    const ad=new Ad();
    const adP= new AdPosition();
    adP.name="hello";
    ad.name="hello";
    ad.adPosition=adP;
    return await this.adRepository.save(ad);
  }
}
